package com.pctx.bibatracker.controller;


import com.pctx.bibacommon.result.Result;
import com.pctx.bibatracker.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@CrossOrigin
@RestController
@RequestMapping("/map")
public class PositionController {
    @Autowired
    private PositionService positionService;

    /**
     * 调取GPS传回来的数据
     *
     * @param cord_x
     * @param cord_y
     * @param cord_z
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/getPosition")
    public Result getPosition(BigDecimal cord_x, BigDecimal cord_y, BigDecimal cord_z, String deviceNo) throws Exception {
        return positionService.getPosition(cord_x, cord_y, cord_z, deviceNo);
    }

    /**
     * 定位
     *
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/getCurrentPosition")
    public Result getCurrentPosition(String deviceNo) throws Exception {
        return positionService.getCurrentPosition(deviceNo);
    }

    /**
     * 将WGS-84转换成高德坐标
     *
     * @param deviceNo
     * @return
     * @throws Exception
     */
    @RequestMapping("/getCurrentPositionFromGaoDe")
    public Result getCurrentPositionFromGaoDe(String deviceNo) throws Exception {
        return positionService.getCurrentPositionFromGaoDe(deviceNo);
    }

}
